home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 8
/
FM Towns Free Software Collection 8.iso
/
t_os
/
clcl
/
clcl.c
< prev
next >
Wrap
Text File
|
1994-06-01
|
7KB
|
287 lines
// 時報消し
#include <egb.h>
#include <mos.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
#include "Platform.h"
#include "aoi_lib2.h"
#define APPNAME "clcl.exp"
void clearClockEasy3(int x0, int y0, int x1, int y1, int pageORG, int pageSCR, int pageBUF)
{
int x, y;
int lenX;
char buf1[4];
char buf2[4];
char buf3[4];
char buf4[4];
char Sbuf[360 * 2];
lenX = x1 - x0;
y1++;
EGB_writePage(work, pageORG);
AOIgetGraph(buf1, x0, y0, x0, y0);
AOIgetGraph(buf2, x0, y1, x0, y1);
AOIgetGraph(buf3, x1, y0, x1, y0);
AOIgetGraph(buf4, x1, y1, x1, y1);
EGB_writePage(work, pageBUF);
AOIputGraph(buf1, 0, 0, 0, 0);
EGB_writeMode(work, 7);
EGB_pastel(work, 64);
AOIputGraph(buf2, 0, 0, 0, 0);
AOIputGraph(buf3, 0, 0, 0, 0);
AOIputGraph(buf4, 0, 0, 0, 0);
AOIgetGraph(Sbuf, 0, 0, 0, 0);
for (x = 0; x <= lenX; x++) {
AOIputGraph(Sbuf, x, 0, x, 0);
}
AOIgetGraph(Sbuf, 0, 0, lenX, 0);
EGB_writeMode(work, 0);
EGB_writePage(work, pageSCR); // 直接、表示画面に描画
for (y = y0; y < y1; y++) {
AOIputGraph(Sbuf, x0, y, x1, y);
}
}
void clearClockEasy2(int x0, int y0, int x1, int y1, int pageORG, int pageSCR, int pageBUF)
{
int y;
int lenX;
char buf1[360 * 2];
char buf2[360 * 2];
char Sbuf[360 * 2];
lenX = x1 - x0;
y1++;
for (y = y0; y < y1; y++) {
EGB_writePage(work, pageORG);
AOIgetGraph(buf1, x0, y0, x1, y0);
EGB_writePage(work, pageBUF);
AOIputGraph(buf1, 0, 0, lenX, 0); // 上ライン
EGB_writePage(work, pageORG);
AOIgetGraph(buf2, x0, y1, x1, y1);
EGB_writePage(work, pageBUF);
EGB_writeMode(work, 7);
EGB_pastel(work, 128);
AOIputGraph(buf2, 0, 0, lenX, 0); // 上ラインに下ライン重ね
AOIgetGraph(Sbuf, 0, 0, lenX, 0);
EGB_writeMode(work, 0);
EGB_writePage(work, pageSCR); // 直接、表示画面に描画
AOIputGraph(Sbuf, x0, y, x1, y);
}
}
void clearClockEasy(int x0, int y0, int x1, int y1, int pageORG, int pageSCR, int pageBUF)
{
int y;
int lenX;
char buf1[360 * 2];
char buf2[360 * 2];
char Sbuf[360 * 2];
lenX = x1 - x0;
y1++;
EGB_writePage(work, pageORG);
AOIgetGraph(buf1, x0, y0, x1, y0);
AOIgetGraph(buf2, x0, y1, x1, y1);
EGB_writePage(work, pageBUF);
AOIputGraph(buf1, 0, 0, lenX, 0); // 上ライン
EGB_writeMode(work, 7);
EGB_pastel(work, 128);
AOIputGraph(buf2, 0, 0, lenX, 0); // 上ラインに下ライン重ね
AOIgetGraph(Sbuf, 0, 0, lenX, 0);
EGB_writeMode(work, 0);
EGB_writePage(work, pageSCR); // 直接、表示画面に描画
for (y = y0; y < y1; y++) {
AOIputGraph(Sbuf, x0, y, x1, y);
}
}
void clearClock(int x0, int y0, int x1, int y1, int pageORG, int pageSCR, int pageBUF)
{
int y, gap;
int lenX, lenY;
double pasGap, pas;
char buf1[360 * 2];
char buf2[360 * 2];
char *Sbuf;
lenX = x1 - x0;
lenY = y1 - y0;
gap = lenY - 1;
pasGap = 256 / (double)lenY;
Sbuf = (char *)malloc(lenX * lenY * 2 * sizeof(char));
if (Sbuf == NULL) return;
EGB_writePage(work, pageORG);
AOIgetGraph(buf1, x0, y0, x1, y0);
AOIgetGraph(buf2, x0, y1, x1, y1);
EGB_writePage(work, pageBUF);
for (y = 0; y < gap; y++) {
AOIputGraph(buf1, 0, y, lenX, y);
}
EGB_writeMode(work, 7);
for (y = lenY, pas = 256; y >= 0; y--, pas -= pasGap) {
EGB_pastel(work, pas);
AOIputGraph(buf2, 0, y, lenX, y);
}
AOIgetGraph(Sbuf, 0, 0, lenX, lenY);
EGB_writeMode(work, 0);
EGB_writePage(work, pageSCR);
AOIputGraph(Sbuf, x0, y0, x1, y1);
free(Sbuf);
}
void pointing(int *x0, int *y0, int *x1, int *y1)
{
char mes[2][AOImbMaxSize];
int x, y, button;
int dx, dy;
strcpy(mes[0], " 処理範囲をマウスで");
strcpy(mes[1], "指定してください。");
if (AOImessageBox(180, 120, 16, APPNAME, 2, mes, MB_OKCANCEL) == ID_OK) {
MOS_disp(1);
do {
MOS_rdpos(&button, &x, &y);
} while (button); // 一端マウスボタンを離さないと受け付けない
do {
MOS_rdpos(&button, &x, &y);
} while (!button);
dx = x;
dy = y;
do {
MOS_rdpos(&button, &x, &y);
MOS_disp(0);
AOIbox(dx, dy, x, y, 0);
AOIbox(dx, dy, x, y, 0x8000);
MOS_disp(1);
} while (button);
MOS_disp(0);
*x0 = dx;
*y0 = dy;
*x1 = x;
*y1 = y;
EGB_writeMode(work, 10);
AOIboxFull(0, 0, 360, 240, 0xffffffff);
EGB_writeMode(work, 0);
}
}
void endSet(int *endMark)
{
char mes[1][AOImbMaxSize];
strcpy(mes[0], "終了しますか?");
if (AOImessageBox(180, 120, 16, APPNAME, 1, mes, MB_YESNO) == ID_YES) {
*endMark = 1;
}
}
void main(int argc, char *argv[])
{
int endMark = 0;
int x, y, button;
int x0, y0, x1, y1;
int mode = 0;
char buf[320 * 240 * 2];
if (argc != 5) {
x0 = 25; // デフォルト値設定
y0 = 20;
x1 = 100;
y1 = 44;
} else {
x0 = atoi(argv[1]);
y0 = atoi(argv[2]);
x1 = atoi(argv[3]);
y1 = atoi(argv[4]);
}
MOS_start(mwork, 4096);
EGB_init(work, 1536);
EGB_resolution(work, 0, 9);
EGB_resolution(work, 1, 9);
EGB_resolutionRam(work, 0x80, 16, 320, 240, buf);
EGB_displayPage(work, 0, 3);
EGB_displayStart(work, 2, 2, 2);
EGB_displayStart(work, 3, 360, 240);
EGB_writePage(work, 0);
EGB_writeMode(work, 10);
AOIboxFull(0, 0, 360, 240, 0xffffffff);
EGB_writeMode(work, 0);
EGB_superImpose(work, 65);
EGB_writePage(work, 1);
EGB_digitize(work, 1);
MOS_resolution(0, 9);
MOS_color(1, 0xf8f8f8);
MOS_typeRom(80 + 1, 0, 0, pat_work);
do {
switch (mode) {
case 0 :
clearClock(x0, y0, x1, y1, 1, 0, 0x80); // 段階的変化モード
break;
case 1 :
clearClockEasy(x0, y0, x1, y1, 1, 0, 0x80); // 平均モード
break;
case 2 :
clearClockEasy2(x0, y0, x1, y1, 1, 0, 0x80);// 随時変化平均モード
break;
case 3 :
clearClockEasy3(x0, y0, x1, y1, 1, 0, 0x80);
break;
}
MOS_rdpos(&button, &x, &y);
if (button) {
for (int i = 0; i < 20000; i++) ; // チョン押し誤動作防止
MOS_rdpos(&button, &x, &y);
switch (button) {
case 1 :
pointing(&x0, &y0, &x1, &y1); // 範囲指定
break;
case 2 :
endSet(&endMark); // 終了処理
break;
case 3 :
mode++; // モード変更
if (mode == 4) mode = 0;
break;
}
button = 0;
MOS_disp(0);
do {
MOS_rdpos(&button, &x, &y);
} while (button); // 一端マウスボタンを離さないと受け付けない
}
// if (kbhit()) endMark++;
} while (!endMark);
MOS_disp(0);
MOS_end();
}